 #define _CRT_SECURE_NO_WARNINGS
#include<iostream>
using namespace std;
class Solution {
public:
    bool isLetterOrNumber(const char& c)
    {
        return ((c >= '0' && c <= '9') 
            || (c >= 'a' && c <= 'z') 
            || (c >= 'A' && c <= 'Z'));
    }
    bool isPalindrome(string s) {
        //这里不能是size_t类型，会报错
        int left = 0, right = s.size() - 1;
        for (auto& ch : s)
        {
            ch = tolower(ch);
        }

        while (left < right)
        {
            while (!isLetterOrNumber(s[left]) && left < right)
            {
                left++;
            }
            while (!isLetterOrNumber(s[right]) && left < right)
            {
                right--;
            }
            if (s[left] == s[right])
            {
                left++;
                right--;
            }
            else
                return false;
        }
        return true;
    }
};
int main()
{
    Solution aaa;
    cout<<aaa.isPalindrome("race a car")<<endl;
    return 0;
}